#ifndef ANALYSIS_CPP
#define ANALYSIS_CPP
#include "Analysis.h"



namespace Analysis
{
		static float differentiate( double x, double(*func)(double) )
		{
			return ( ( func( x + GeoMath::EPS ) - func( x ) ) / GeoMath::EPS );
		}

		// Create a Jacobi Matrix by differentiate one Vector3 function with 3 variables.
		static Matrix3 GetJacobiMatrix3( Vector3 x123,  Vector3(*func)( const Vector3& ) )
		{
			Vector3 toX1( x123.getX() + GeoMath::EPS,x123.getY(),x123.getZ() );
			Vector3 toX2( x123.getX(),x123.getY() + GeoMath::EPS,x123.getZ() );
			Vector3 toX3( x123.getX(),x123.getY(),x123.getZ() + GeoMath::EPS );

			Vector3 funcY1 = ((func(toX1) - func(x123)) / GeoMath::EPS);
			Vector3 funcY2 = ((func(toX2) - func(x123)) / GeoMath::EPS);
			Vector3 funcY3 = ((func(toX3) - func(x123)) / GeoMath::EPS);

			Matrix3 jmat(
				funcY1.getX(),funcY2.getX(),funcY3.getX(),
				funcY1.getY(),funcY2.getY(),funcY3.getY(),
				funcY1.getZ(),funcY2.getZ(),funcY3.getZ()
			);

			return jmat;
		}
}
#endif
